import { Component, OnInit } from '@angular/core';
import { fromEvent } from 'rxjs';
import { ViewsserviceService } from '../../../services/viewsservice.service';
import { HttpService } from '../../../services/http.service';
import { opusUrl, glanceOverimageUrl } from '../../../urlConfig'
@Component({
  selector: 'app-oeuvre',
  templateUrl: './oeuvre.component.html',
  styleUrls: ['./oeuvre.component.styl']
})
export class OeuvreComponent implements OnInit {


  public nzSpan: number; // 栅格数
  list: any[] = [];// 当前要渲染的数据
  lists: any[] = [];// 全部数据
  imgPrefixUrl: string = glanceOverimageUrl; // 预览图片地址前缀

  constructor(
    public service: ViewsserviceService,
    public http: HttpService) { }

  ngOnInit() {

    this.http.getData(opusUrl).subscribe((event: any) => {
      if (event.code === 200) {
        this.lists = event.data;
        // 刚一进入页面时显示第一页的内容
        this.list = [];
        this.lists.forEach((currentValue: any, index: number) => {
          if (index < 9) {
            this.list.push(currentValue)

          }
        })
      }
    });
  }

  // 页码改变的回调
  skip(number) {
    this.list = [];
    this.lists.forEach((currentValue: any, index: number) => {
      if (number * 9 - 9 <= index && number * 9 > index) {
        this.list.push(currentValue)

      }
    })

  }
}
